package com.kwedding.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.kwedding.dto.web.RequestWebAccountList;
import com.kwedding.dto.web.RequestWebAddAccount;
import com.kwedding.dto.web.RequestWebUpDownAccount;
import com.kwedding.dto.web.RequestWebUpdateAccount;
import com.kwedding.dto.web.ResponseWebAccountList;
import com.kwedding.service.web.WebAccountService;
import com.kwedding.util.BackJson;
import com.kwedding.util.JsonBack;
import com.kwedding.util.JsonBackBase;
import com.kwedding.util.LoggerParent;
import com.kwedding.util.Resp_PageInfo;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@Controller
@RequestMapping("/rest/web/account")
@Api(tags = "App用户管理")
public class WebAccountController extends LoggerParent {

	@Autowired
	private WebAccountService webAccountService;

	@ApiOperation(" 添加APP账号")
	@ResponseBody
	@RequestMapping(value = "insertAccount", method = { RequestMethod.POST })
	private JsonBack insertAccount(@RequestBody RequestWebAddAccount requestWebAddAccount) {
		webAccountService.insertAccount(requestWebAddAccount);
		return BackJson.success();
	}

	@ApiOperation(" 获取用户列表")
	@ResponseBody
	@RequestMapping(value = "getAccountList", method = { RequestMethod.POST })
	private JsonBackBase<Resp_PageInfo<ResponseWebAccountList>> getAccountList(
			@RequestBody RequestWebAccountList accountList) {
		return BackJson.successObj(webAccountService.getAccountList(accountList));
	}

	@ApiOperation(" 修改APP信息")
	@ResponseBody
	@RequestMapping(value = "upDateAccount", method = { RequestMethod.POST })
	private JsonBack upDateAccount(@RequestBody RequestWebUpdateAccount webUpdateAccount) {
		webAccountService.upDateAccount(webUpdateAccount);
		return BackJson.success();
	}

	@ApiOperation(" 下架APP账号")
	@ResponseBody
	@RequestMapping(value = "upDownAccount", method = { RequestMethod.POST })
	private JsonBack upDownAccount(@RequestBody RequestWebUpDownAccount upDownAccount) {
		webAccountService.upDownAccount(upDownAccount);
		return BackJson.success();
	}
}
